<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html style="height: 100%;">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   	<link href="/Public/Admin/css/selector/selectorstyle.css" rel="stylesheet"/>
   	 <link href="/Public/Admin/js/bootstrap/css/bootstrap.min.css?2025" rel="stylesheet" type="text/css" />
    <style>
		.btn{
			font-size: 12px; 
			padding: 3px 12px;
		}
		.gray-bg{
			min-width: 0px; border: 1px solid #ddd; height: 100%;
			padding: 5px;
		}
    </style>
</head>
<body class="gray-bg" >
	<div>
		<ul id="treeFrom" class='ztree'></ul>
	</div>
	<div style="border-top:1px solid #ddd; padding-top: 10px;">
		<button id="Preservation" type="button" class="btn btn-default" style="margin-left:30%;" onclick="getChecked()">保存</button>
		&nbsp;&nbsp;&nbsp;<button id="cancel" type="button" class="btn btn-danger" onclick="layerClose()">取消</button>
	</div>
</body>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/plugins/selector/jquery.ztree.all.js"></script>
<script>
	$(function(){
		data = {
			checkType : "checkbox",
			inputname : "",
			inputid : "",
			callback : ""
		}
		var url = "/index.php?m=Admin&c=Form&a=fromtreeData&id=0";
	 	var setting = {
			view: {
				selectedMulti: false, //设置是否能够同时选中多个节点
				showIcon: true, //设置是否显示节点图标
				showLine: true, //设置是否显示节点与节点之间的连线
				showTitle: true, //设置是否显示节点的title提示信息
			},
			data: {
				simpleData: {
				enable: true, //设置是否启用简单数据格式
				idKey: "id", //设置启用简单数据格式时id对应的属性名称
				pidKey: "pid" //设置启用简单数据格式时parentId对应的属性名称
				}
			},
			check:{
				enable: true,  //设置是否显示checkbox复选框
			  	chkStyle: data.checkType, //单选框
			  	radioType: "all", //对所有节点设置单选
			  	chkboxType:  { "Y": "", "N": "" }
			},
			callback: {

				onAsyncSuccess: ztreeOnAsyncSuccess,//每次异步获取数据回调函数

			},
			async: {
				enable: true,   //设置启用异步加载
				type: "post",   //异步加载类型:post和get
				contentType: "application/json", //定义ajax提交参数的参数类型，一般为json格式
				url: url,  //定义数据请求路径
				autoParam: ["id=id"] //定义提交时参数的名称，=号前面标识节点属性，后面标识提交时json数据中参数的名称
			}
		};
	    treeObj = $.fn.zTree.init($("#treeFrom"), setting);
	    
	});
	
	
	
	function ztreeOnAsyncSuccess(event, treeId, treeNode){}

	function layerClose(){
		var index = parent.layer.getFrameIndex(window.name);  
		parent.layer.close(index); 
	}
	
	function getChecked(){
		var nodes = treeObj.getCheckedNodes(true);
		parent.setBPformRight(nodes);
		layerClose();
	}
	
</script>
</html>